<!-- 后台管理页面 -->
<template>
    <div class="main-panel">
        <div class="menus">
             <div v-for="(menu,index) in menus" @click="toPage(menu)">
                {{ menu.name }}
            </div>
        </div>
        <div style="padding: 20px;width: 100%;">
            <!-- 路由节点 -->
             <router-view>

             </router-view>
        </div>
    </div>
    <div class="title">后台管理系统</div>
</template>

<script setup>



    import { AdminStore } from '../../stores/AdminStore'
    import { ref,reactive,inject ,onMounted } from 'vue'
    // 引入路由模块
    import { useRouter, useRoute } from 'vue-router'
    const router =  useRouter()
    const route = useRoute()

 
    // 信息标签实例化
    const message = inject("message")
    const axios = inject("axios")
    // 拿到用户信息 
    // 刷新页面之后，登录状态就会被取消掉
    
    const adminstore = AdminStore()

    // 定义左侧菜单项
    let menus = [
        {name: "文章管理",href:"/dashboard/article"},
        {name: "分类管理",href:"/dashboard/category"},
        {name: "退出",href:"logout"},
    ]

    const toPage = (menu)=>{
        if(menu.href == 'logout'){
            // 表示退出登录
            router.push("/login")
        }
        else{
            router.push(menu.href)
        }
    }
 
    onMounted(()=>{
        console.log("Dashboard!")
        toPage(menus[0])
    })


</script>

<style lang="scss" scoped>
.main-panel{
    display: flex;
    color: #64676a;
    max-width: 1900px;
    min-width: 1500px;
    margin: 0 auto;
}

.menus{
    padding: 20px 0;
    box-sizing: border-box;
    line-height: 55px;
    text-align: center;
    width: 180px;
    height: 95vh;
    border-right: 1px solid #dadada;

    div{
        cursor: pointer;
        &:hover{
            color: #fd760e;
        }
    }
}

.title{
    font-size: 65px;
    font-weight: bold;
    text-align: right;
    position: fixed;
    color: rgba(0,0,0,20%);
    right: calc((100vw - 1500px) /2);
    bottom: 20px;
}
</style>